package com.coldworks.base;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.coldworks.base.manager.BaseConfManager;
import com.coldworks.base.util.BaseLoggerFactory;
import com.umeng.analytics.MobclickAgent;

import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;

public class BaseFragmentActivity extends FragmentActivity {
	protected final Logger log = LoggerFactory.getLogger(this.getClass());
	protected Context context;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		try {
			this.context = (Context) this;
			BaseLoggerFactory.init(context, BaseConfManager.getInstance()
					.getVersionCode(context), true);
		} catch (Exception e) {
			log.error("",e);
		}
	}

	@Override
	protected void onPause() {
		super.onPause();
		try {
			MobclickAgent.onPause(this);
		} catch (Exception e) {
			log.error("",e);
		}
	}

	@Override
	protected void onResume() {
		super.onResume();
		try {
			MobclickAgent.onResume(this);
		} catch (Exception e) {
			log.error("",e);
		}
	}

	@Override
	protected void onStop() {
		super.onStop();
		try {
			log.info("log: " + BaseLoggerFactory.notifyStop() + " byte."); // 每次这个方法验证log是否足够，是否可停止logcat
		} catch (Exception e) {
			log.error("",e);
		}
	}

}
